﻿using System;
using LastFmLib.API20;
using LastFmLib.API20.Types;

namespace Mp3Tagger
{

	public class LastfmWorker
	{

		static readonly LastFmLib.MD5Hash API_KEY = new LastFmLib.MD5Hash(api_resource.api_key, true);
		static readonly LastFmLib.MD5Hash API_SECRET = new LastFmLib.MD5Hash(api_resource.api_secret, true);
		//	static LastFmLib.MD5Hash SESSION_KEY = new LastFmLib.MD5Hash(My.Resources.api_ressource.session_key);

		public LastfmWorker()
		{
			Settings.AuthData = new AuthData(API_KEY, API_SECRET, null);
		}

		public Uri GetAlbumArtUri(string artist, string album)
		{
			var rq = new LastFmLib.API20.Album.AlbumGetInfo(artist,album) {RequestMode = modEnums.RequestMode.Rest};
		    rq.Start();
			if (rq.succeeded)
			{
				return rq.Result.ImageLarge;
			}
			else
			{
				Console.WriteLine("Album.AlbumGetInfo failed(" + rq.FailureCode + "):" + rq.errorMessage);
				return null;
			}
		}

	}
}
